<template>
  <div class="product-manage" >
    <!--    <el-button type="primary" @click="showAddDialog">添加商品</el-button>-->
    <el-table  highlight-current-row :data="feedbacks"  style="width: 100%">
      <el-table-column prop="fid" label="编号" width="250" ></el-table-column>
      <el-table-column prop="fname" label="反馈标题"></el-table-column>
      <el-table-column prop="content" label="反馈内容"></el-table-column>
      <el-table-column prop="date" label="反馈时间"></el-table-column>
      <el-table-column prop="name" label="反馈者"></el-table-column>
      <el-table-column prop="phone" label="反馈者联系方式" width="150"></el-table-column>
      <el-table-column width="150" label="操作">

        <template slot-scope="scope">
          <el-button size="small"  type="danger" @click="deleteProduct(scope.row,scope.$index,feedbacks)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios'
import { Message, MessageBox } from 'element-ui'

export default {
  data() {
    return {
      feedbacks: [],
    }
  },
  mounted() {
    this.getOrders()
  },
  methods: {
    getOrders() {
      axios.get('http://localhost:8088/user_b/findAllFeedBack')
          .then(response => {
            console.log(response.data.data)
            this.feedbacks = response.data.data
            // this.categories=response.data.categories
          })
          .catch(error => {
            console.log(error)
          })
    },
    deleteProduct(feedback,index,rows) {
      MessageBox.confirm('此操作将永久删除该反馈, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            axios.delete('http://localhost:8088/user_b/delFeedBackByFID',{params:{
                fid:feedback.fid
              }})
                .then(() => {
                  // this.getProducts()
                  rows.splice(index,1);
                  Message.success('删除成功')
                })
                .catch(error => {
                  console.log(error)
                })
          })
          .catch(() => {
            // do nothing
          })
    }
  }
}
</script>

<style scoped> .product-manage { padding: 20px; } </style>
